﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using cbmobile.DAC;
using cbmobile.BLC;
using System.Data;
using System.Data.SqlClient;


namespace cbmobile.BLC
{
    public class TimKiem
    {
        CBMobileEntities da = new CBMobileEntities();
        BLC_SanPham nBLC = new BLC_SanPham();

        public IList<SanPham> SearchSP(string TenSP)
        {
            IList<SanPham> list= da.SanPhams.Where(z => z.Ten_SP.Contains(TenSP)).ToList();
            if (list.Count == 0)
                return null;
            return list;
        }

        public IList<PhuKien> SearchPK(string TenPK)
        {
            IList<PhuKien> list = da.PhuKiens.Where(z => z.Ten_PhuKien.Contains(TenPK)).ToList();
            if (list.Count() == 0)
                return null;
            return list;
        }

        public IList<LinhKien> SearchLK(string TenLK)
        {
            IList<LinhKien> list = da.LinhKiens.Where(z => z.TenLinhKien.Contains(TenLK)).ToList();
            if(list.Count()==0)
                return null;
            return list;
        }

        public HangSanXuat SearchHSX(string TenHSX)
        {
            IList<HangSanXuat> list = da.HangSanXuats.Where(z => z.TenHangSX.Contains(TenHSX)).ToList();
            if (list.Count() == 0)
                return null;
            return list.First();
        }


        public IList<SanPham> Get_SP_By_IDMaHSX(int MaHSX)
        {
            IList<SanPham> list = da.SanPhams.Where(z => z.HangSX_ID == MaHSX).ToList();
            if (list.Count() == 0)
                return null;
            return list;
        }
        
    }
}